package es.albarregas.controladores;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CtrlProcesarLogin extends HttpServlet {
	
	private static final long serialVersionUID = 1L;
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		procesarPeticion(request, response);
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		procesarPeticion(request, response);
	}	
	private void procesarPeticion(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {		
		String cadenaBusqueda = new String("");
		cadenaBusqueda = "where email=\'"+request.getParameter("email")+
				"\' and clave=password(\'"+request.getParameter("password")+"\')";
		System.out.println("Cadena de busqueda en servlet " + cadenaBusqueda);
		
		RequestDispatcher rd = request.getRequestDispatcher("CtrlLogin.jsp");		
		request.setAttribute("clausulaUsuarios", cadenaBusqueda);
		rd.forward(request, response);
	}

}
